package cn.com.aiouyi.common;

import cn.com.aiouyi.util.SpringUtils;

/**
 * Created by tommy on 2018/3/30.
 */
public enum ExceptionCode {
    /**
    * General error
     * from 10100000 to 10999999
    * */
	ExceptionError("10100000", "exception.system.exceptionError"),
    InsertError("10100001", "exception.system.insertFailed"),
    UpdateError("10100002", "exception.system.updateFailed"),
    DeleteError("10100003", "exception.system.deleteFailed"),
    HiddenError("10100004", "exception.system.hiddenFailed"),
    NullError("10100005", "exception.system.nullValue"),
    EmptyError("10100006", "exception.system.emptyValue"),
    CastError("10100007", "exception.system.castError"),

    CodeRepeatError("10100008","exception.system.codeRepeat"),
    ResultIsNotUnique("10100009","exception.system.TooManyResultsException"),

    UpdateIdNotEqual("10100010", "exception.system.updateIdNotEqual"),
    MethodInvokeError("10100011", "exception.system.methodInvokeError"),
    LoginPrincipalError("10100011", "exception.system.LoginPrincipalError"),

    FileSuffixInvalid("10100012", "exception.system.fileSuffixInvalid"),
    FileUploadFail("10100012", "exception.system.fileUploadFail"),
    /**
     * 系统设置  11
     *    系统设置 10
     *    系统日志 11
     *    插件配置 12
     *    数据字典 13
     *    组织架构 14
     *    角色管理 15
     *    用户管理 16
     * from     11100000 to 11999999
     */
    PluginConfig_pluginIdNotExist("11120001", "exception.system.pluginConfig.pluginIdNotExist"),

    //End
    MeaningLessError("10000000", "Not used");

    private String code;
    private String message;

    ExceptionCode(String code, String message){
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString(){
        return "[" + this.code + "] " + SpringUtils.getMessage(this.message);
    }
}
